<?php
$link = mysqli_connect("localhost","root","123456","transaction");
$sql = "UPDATE user LEFT JOIN inform_list ON user.user_id =inform_list.u_id SET user.user_name = '{$_POST['newname']}',inform_list.user_name = '{$_POST['newname']}' WHERE user_id= '{$_POST['u_id']}'";//修改昵称
// UPDATE table1 

//     LEFT JOIN table2 ON table1.xx=table2.xx (关联的字段)

//     SET table1.xx=value,table2.xx=value （update value）

// WHERE table1.xx=xx （条件）
$consql =  "UPDATE user LEFT JOIN calllist ON user.user_id = calllist.c_id  SET user.user_email = '{$_POST['newcon']}', calllist.c_contace = '{$_POST['newcon']}'  WHERE user.user_id= '{$_POST['u_id']}'";//修改联系方式
$consql2 =  "UPDATE inform_list LEFT JOIN calllist ON inform_list.u_id = calllist.u_id  SET inform_list.contace = '{$_POST['newcon']}', calllist.u_contace = '{$_POST['newcon']}'  WHERE inform_list.u_id= '{$_POST['u_id']}'";//修改联系方式
$data = [];
if($_POST['newname']){
	$res = mysqli_query($link,$sql);
	if(mysqli_affected_rows($link)>0){
		$data['info'] = "修改成功";
		$data['status'] = "1";
	}else{
		$data['info'] = "修改失败";
		$data['status'] = "0";
	}
	echo json_encode($data);
	// echo json_encode($sql);
}
if($_POST['newcon']){
	mysqli_query($link,$consql);
	mysqli_query($link,$consql2);
	if(mysqli_affected_rows($link)>0){
		$data['info'] = "修改成功";
		$data['status'] = "1";
	}else{
		$data['info'] = "修改失败";
		$data['status'] = "0";
	}
	echo json_encode($data);
	// echo json_encode($consql2);
}












?>